#include "head.h"


void system_init(puser* ppuhead, puser* pputail, pcustomer* pphead, pcustomer* pptail)
{
	FILE* fp = fopen("configuration.txt", "r");
	if (NULL == fp)
	{
		perror("fopen");
	}
	char arg[4][100] = { 0 };
	int j;
	for (j = 1; j < 4; ++j)
	{
		fscanf(fp, "%s", arg[j]);
	}
	
	//int ret=strcmp(arg[1], "hotel_info\\hotel-admin-info.txt");
	//printf("%d\n", ret);
	FILE* fp1 = fopen(arg[1], "r");//文件指针文件指针*不能忘了加
	if (NULL == fp1)
	{
		perror("fopen");
		return;
	}
	FILE* fp2 = fopen(arg[2], "r");
	if (NULL == fp2)
	{
		perror("fopen");
		return;
	}
	FILE* fp3 = fopen(arg[3], "r");
	if (NULL == fp3)
	{
		perror("fopen");
		return;
	}

	/********************客户**********************/
	int id;
	char name[20];
	int room_num;
	/********************用户**********************/
	char uname[20];
	char pass[20];
	int right;
	/****************读取用户信息******************/
	while (fscanf(fp1, "%s%s%d", uname, pass, &right) != EOF)
	{
		userInsert(ppuhead, pputail, uname, pass, right);
	}
	/****************读取客户信息******************/
	while (fscanf(fp2, "%d%s%d", &id, name, &room_num) != EOF)
	{
		tailInsert(pphead, pptail, id, name, room_num);
	}
	fclose(fp1);
	fclose(fp2);
	fclose(fp3);
}
